﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PictrueSimpleSyndication
{
    public struct Anchor
    {
        public Anchor(double x, double y)
        {
            X = x;
            Y = y;
        }

        public double X, Y;
    }

    public static class ControlEx
    {
        public static Point GetAnchrPoint(this Control _control, double x, double y)
        {
            return _control.GetAnchrPoint(new Anchor(x, y));
        }

        public static Point GetAnchrPoint(this Control _control, Anchor anchor)
        {
            return new Point((int)(_control.Width * anchor.X), (int)(_control.Height * anchor.Y));
        }

        public static void SetPositionByAnchr(this Control _control, Point point, Anchor anchor)
        {
            _control.Location = PointEx.PointSum(point, _control.GetAnchrPoint(-anchor.X, -anchor.Y));
        }
    }
}
